"""
@author: lyf
@file: 高阶函数练习.py
@time: 2022/12/11 17:37
"""
def f(x):
    if type(x) == str:
        return x
lst = [1,2,"x","xy"]
print(list(filter(f,lst)))

from functools import reduce
print(reduce(lambda x,y:x*y,range(1,10)))

def chu(x):
    if x % 3 == 0:
        return x
print(list(filter(chu,range(1,101))))

def p(x):
    return x**2
print(list(map(p,range(1,11))))

print(reduce(lambda x,y:str(x)+str(y),[1,4,5,9]))

s = 'asdf234GDSdsf23'
print("".join(sorted(s, key=lambda x: (x.isdigit(), x.isdigit() and int(x)%2==0, x.isupper(),x))))